home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Tutorial / Script1.vu < prev    next >
Encoding:
Text File  |  1998-06-04  |  3.4 KB  |  94 lines  |  [TEXT/MPS ]

  1. # **********************************************************************
  2. #
  3. # File:                Script 1.vu
  4. #
  5. # Purpose:            to demonstrate some of the basic principles
  6. #                    of Virtual User
  7. #
  8. # Prerequisites:    This script assumes that DrawShapesVU is the
  9. #                    currently active application on the target,
  10. #                    that the file VU Tutorial 1.ds is in the
  11. #                    same folder as the application.
  12. #
  13. # Written by:        David Gaxiola
  14. #
  15. # Copyright © 1992 by Apple Computer, Inc., all rights reserved.
  16. #
  17. # **********************************************************************
  18.  
  19. # Begin main body. ******************************************************
  20.  
  21. # Set up the system so that the mouse moves fairly slowly. This allows 
  22. # you to watch the actions as they are performed on the target.
  23.  
  24. mouseSpeed( 12 );
  25.  
  26. # Open a DrawShapesVU document to test
  27.  
  28. println "# Opening 'VU Tutorial 1.ds' document.";
  29. select [ menuItem title:'Open' menu:[ menu title:'File' ] ]; 
  30. type keystrokes:{ 'VU Tutorial 1.ds' }; # Type the filename in the open file 
  31.                                         # dialog box.
  32. select [ button title:'Open' ];
  33. while not match [window ordinality:1 title:'VU Tutorial 1.ds'] 
  34. begin
  35.     Wait(1);
  36. end;
  37.  
  38. # The previous while loop gives slower target machines an opportunity to
  39. # completely open the document window on the screen before the drag and
  40. # size commands are executed in the next step. If this loop is left out
  41. # of the script and the target machine is not able to draw the window 
  42. # quickly enough, VU will not be able to find a match for the window
  43. # specified in the drag and size command statements.
  44.  
  45. # Position and size the document window. This example sets the window
  46. # size to the smallest Macintosh screen size:  9".
  47. println "# Setting up window.";
  48. drag [window title:'VU Tutorial 1.ds'] absolute:{ 1, 21 };
  49. size [window title:'VU Tutorial 1.ds'] width:510 height:320;
  50.  
  51. # If the VU Tutorial 1.ds window is not open, the drag and size commands 
  52. # will select points either somewhere on the Finder desktop or in
  53. # windows other than the one specified. VU may indicate a match failure
  54. # and the script will not behave correctly.
  55.  
  56. # Select the pointer tool, then select the "eyes" in the drawing.
  57.  
  58. println "# Selecting objects.";    
  59. move absolute:{ 20, 59 };            # move to the pointer tool position.    
  60. click;
  61. move relative:{ 147, 50 };            # relative offset from the current cursor
  62. pressKey keyStrokes:{ shiftKey };    # position in the document window
  63. click;
  64. move relative:{ 174,0 };
  65. click;
  66. releaseKey keyStrokes:{ shiftKey };
  67.  
  68. # Copy the eyes to the clipboard and paste them back in the window.
  69. println "# Performing 'copy' and 'paste' operation.";
  70. select [ menuItem title:'Copy' menu:[ menu ordinal:3 ]];
  71. select [ menuItem title:'Paste' menu:[ menu title:'Edit' ]];
  72.  
  73. # Close the window.
  74. println "# Discarding changes.";
  75. close [ window title:'VU Tutorial 1.ds' ];
  76. while not match [ button title:"No" window:1 ]
  77. begin
  78.     wait(1);
  79. end;
  80.  
  81. # The previous while loop waits until the foremost window is a dialog 
  82. # box containing a No button before proceeding to the next step. If this 
  83. # loop is left out of the script and the target machine is not able to 
  84. # draw the dialog box window before VU executes the select statement, VU 
  85. # will not be able to find a match for the dialog box window specified 
  86. # in the select statement.
  87.  
  88. # Select the No button in the Save dialog box.
  89.  
  90. select [ button title:'No' w:[ window s:dialog ]];
  91.  
  92. println "# Finished!";
  93. # End main body. ***************************************************
  94.